#终端输入命令 Terminal-

#初始化 打开git
#D:\mysite>git init

#创建一个django项目
#django-admin startproject HelloWord


#切换端口 启动服务器
#D:\mysite>python manage.py runserver 127.0.0.1:8001


#在数据库插入表
#D:\mysite>python manage.py makemigrations polls
#D:\mysite>python manage.py sqlmigrate polls 0001
#D:\mysite>python manage.py migrate

#表中插入数据
#D:\mysite>python manage.py shell
#>>>from polls.models import Choice,Question
#>>>from django.utils import timezone
#>>>q = Question(question_text="下周五考试？"，pub_date=timezone.now())
#>>>q.save()
#>>>Question.objects.all()
#>>>q.question_text
'下周五考试吗？'
#>>>q.pub_date
#>>>q

#
# D:\mysite>git init
# Initialized empty Git repository in D:/mysite/.git/
#
# D:\mysite>
# D:\mysite>python manage.py runserver 127.0.0.1:8001
# Performing system checks...
#
# System check identified no issues (0 silenced).
# December 14, 2018 - 10:10:12
# Django version 2.1.4, using settings 'mysite.settings'
# Starting development server at http://127.0.0.1:8001/
# Quit the server with CTRL-BREAK.
# Not Found: /
# [14/Dec/2018 10:10:15] "GET / HTTP/1.1" 404 2027
# Not Found: /favicon.ico
# [14/Dec/2018 10:10:16] "GET /favicon.ico HTTP/1.1" 404 2078
# [14/Dec/2018 10:10:28] "GET /polls HTTP/1.1" 301 0
# [14/Dec/2018 10:10:28] "GET /polls/ HTTP/1.1" 200 132
# Performing system checks...
#
# System check identified no issues (0 silenced).
# December 14, 2018 - 10:13:03
# Django version 2.1.4, using settings 'mysite.settings'
# Starting development server at http://127.0.0.1:8001/
# Quit the server with CTRL-BREAK.
# [14/Dec/2018 10:13:13] "GET / HTTP/1.1" 200 132
#
# D:\mysite>python maage.py makemigrations polls
# (null): can't open file 'maage.py': [Errno 2] No such file or directory
#
#
# D:\mysite>python manage.py makemigrations polls
# Migrations for 'polls':
#   polls\migrations\0001_initial.py
#     - Create model Choice
#     - Create model Question
#     - Add field question to choice
#
# D:\mysite>python manage.py sqlmigrate  polls 0001
# BEGIN;
# --
# -- Create model Choice
# --
# CREATE TABLE "polls_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NO
# T NULL);
# --
# -- Create model Question
# --
# CREATE TABLE "polls_question" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "question_text" varchar(200) NOT NULL, "pub_data" dat
# etime NOT NULL);
# --
# -- Add field question to choice
# --
# ALTER TABLE "polls_choice" RENAME TO "polls_choice__old";
# CREATE TABLE "polls_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NO
# T NULL, "question_id" integer NOT NULL REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY DEFERRED);
# INSERT INTO "polls_choice" ("id", "choice_text", "votes", "question_id") SELECT "id", "choice_text", "votes", NULL FROM "polls_choice
# __old";
# DROP TABLE "polls_choice__old";
# CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" ("question_id");
# COMMIT;
#
#
# D:\mysite>python manage.py migrate
# Operations to perform:
#   Apply all migrations: admin, auth, contenttypes, polls, sessions
# Running migrations:
#   Applying polls.0001_initial... OK
#
#
# D:\mysite>python manage.py shell
# Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
# Type "help", "copyright", "credits" or "license" for more information.
# (InteractiveConsole)
# >>> from polls.models import Choice,Question
# >>> from django.utils import timezone
# >>> q =Question(question_text ="下周五考试吗？",pub_date=timezone.now())
# >>> q.save()
# >>> Question.objects.all()
# <QuerySet [<Question: Question object (1)>]>
# >>> q.question_text
# '下周五考试吗？'
# >>> q.pub_date
# datetime.datetime(2018, 12, 14, 3, 25, 56, 504918, tzinfo=<UTC>)
# >>> q
# <Question: Question object (1)>
# >>>



#http://127.0.0.1:8000/admin/polls/choice/
